package logic.table;

import android.provider.BaseColumns;

import logic.constants.DefaultConsts;
import logic.util.logutil.LogUtil;


/**
 * 书签、笔记, 一共20个字段
 * 
 * @author zouqp
 * @date 2014-10-11
 */
public class BookMarksTable
{
	
	public static final String table = "Bookmarks";
	public final class BookMarkColums
	        implements
	        BaseColumns
	{
		public final static String BOOKMARK_ID        = "bookmark_id";
		public final static String BOOK_ID            = "book_id";
		public final static String BOOKMARK_TEXT      = "bookmark_text";     //书签内容
		public final static String CREATION_TIME      = "creation_time";      //
		public final static String MODIFICATION_TIME  = "modification_time";
		public final static String ACCESS_TIME        = "access_time";        //
		public final static String ACCESS_COUNTER     = "access_counter";     //
		public final static String PARAGRAPH          = "paragraph";          //
		public final static String WORD               = "word";            //
		public final static String CHARACTER          = "char";         //
		public final static String MODEL_ID          = "model_id";         //
		public final static String VISIBLE            = "visible";        // 是否可见
		public final static String END_PARAGRAPH      = "end_paragraph";  //
		public final static String END_WORD           = "end_word";           //
		public final static String END_CHARACTER      = "end_character";       //
		public final static String STYLE_ID           = "style_id";          //
		public final static String BOOKNOTE_TEXT      = "booknote_text";     //笔记内容
		public final static String CONTENT_ID         = "content_id";        //内容ID
		public final static String CHAPTER_ID         = "chapter_id";         //章节ID
		public final static String TYPE_ID            = "type_id";          //1书签 2高亮   3笔记  4 位置
		public final static String BOOKMARK_ID_SERVER = "bookmark_id_server"; //服务器端的书签id
	}
	
	public static String getCreateTableSQL() {
		StringBuilder sb = new StringBuilder();
		sb.append("CREATE TABLE IF NOT EXISTS " + table + "(");
		
		sb.append(BookMarkColums.BOOKMARK_ID + " INTEGER PRIMARY KEY AUTOINCREMENT,");
		sb.append(BookMarkColums.BOOK_ID + " INTEGER NOT NULL,");
		sb.append(BookMarkColums.BOOKMARK_TEXT + " TEXT,");
		sb.append(BookMarkColums.CREATION_TIME + " INTEGER NOT NULL,");
		sb.append(BookMarkColums.MODIFICATION_TIME + " INTEGER,");
		sb.append(BookMarkColums.ACCESS_TIME + " INTEGER,");
		sb.append(BookMarkColums.ACCESS_COUNTER + " INTEGER,");
		sb.append(BookMarkColums.PARAGRAPH + " INTEGER NOT NULL,");
		sb.append(BookMarkColums.WORD + " INTEGER NOT NULL,");
		sb.append(BookMarkColums.CHARACTER + " INTEGER NOT NULL,");
		sb.append(BookMarkColums.MODEL_ID + " TEXT,");
		sb.append(BookMarkColums.VISIBLE + " INTEGER DEFAULT 1,");
		sb.append(BookMarkColums.END_PARAGRAPH + " INTEGER,");
		sb.append(BookMarkColums.END_WORD + " INTEGER,");
		sb.append(BookMarkColums.END_CHARACTER + " INTEGER,");
		sb.append(BookMarkColums.STYLE_ID + " INTEGER,");
		sb.append(BookMarkColums.BOOKNOTE_TEXT + " TEXT,");
		sb.append(BookMarkColums.CONTENT_ID + " TEXT,");
		sb.append(BookMarkColums.CHAPTER_ID + " TEXT,");
		sb.append(BookMarkColums.TYPE_ID + " INTEGER,");
		sb.append(BookMarkColums.BOOKMARK_ID_SERVER + " INTEGER");
		sb.append(");");
		LogUtil.d(DefaultConsts.TAG, table + ":" + sb.toString());
		return sb.toString();
	}
}
